<?

require_once("evalable.php");
require_once("pairobject.php");

$__PROPERTIES = array();

class SymbolObject extends Evalable {

    var $n = null;

    function SymbolObject($name) {
        global $__PROPERTIES;
        $this->n = $name;
        if (!array_key_exists($this->n, $__PROPERTIES)) {
            $__PROPERTIES[$this->n] = array();
        }
    }

    function repr() {
        return $this->n;
    }

    function hash() {
        return md5($this->n);
    }

    function lispeval($env, $args=null) {
        return $env->get($this->n);
    }

    function cons($item) {
        return new PairObject($item, $this);
    }

    function nullp() {
        return new LogicObject(0);
    }

    function put($property, $value) {
        global $__PROPERTIES;
        $__PROPERTIES[$this->n][$property] = $value;
    }

    function get($property) {
        global $__PROPERTIES;
        if (isset($__PROPERTIES[$this->n][$property])) {
            return $__PROPERTIES[$this->n][$property];
        } else {
            return new LogicObject(0);
        }
    }

}